package com.wanxi.util;

import java.util.Arrays;
import java.util.Random;

public class IsSameArray {
    public static void main(String[] args) {
        int[] arr1 = setArrData(10);
        System.out.println(Arrays.toString(arr1));
        int[] arr2 = setArrData(10);
        System.out.println(Arrays.toString(arr2));
        double[] arr3 = {1, 2};
        /**
         * 1.提供两个数组
         * 2.判断数据类型是否相同？
         * 3.判断数组的长度是否相同？
         * 4.判断数组内容是否相同？
         *
         */
//        Integer a = 0;
//        Integer b = 0;
//        if (Integer.valueOf(arr1[0] + "") instanceof Integer && Integer.valueOf(arr3[0] + "") instanceof Integer) {
//            System.out.println("a和b的数据类型是相同的");
//        }else {
//            System.out.println("不同");
//        }
        boolean isSameLength = judgeLength(arr1, arr2);
        if (isSameLength) {
            System.out.println("数组长度不相同");
            return;
        }
        judgeContent(arr1, arr2);

    }

    private static void judgeContent(int[] arr1, int[] arr2) {
        for (int i = 0; i < arr1.length; i++) {
            if (arr1[i] != arr2[i]) {
                System.out.println("数组第" + (i + 1) + "个数字不相同");
                return;
            }
        }
    }

    private static boolean judgeLength(int[] arr1, int[] arr2) {
        return arr1.length != arr2.length;


    }

    /**
     * 对数组进行赋初始值
     *
     * @param length
     */
    private static int[] setArrData(int length) {
        int[] arr = new int[length];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new Random().nextInt(10);
        }
        return arr;
    }
}
